package skiree.host.abetsy.api.vessel;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
public class Result {
    private Object data;
    private Meta meta;

    public static Result success(Object data) {
        Result result = new Result();
        result.setData(data);
        result.setMeta(new Meta(200, "执行成功"));
        return result;
    }

    public static Result error(int status) {
        Result result = new Result();
        result.setMeta(new Meta(status, "执行失败"));
        return result;
    }

    public static Result error(int status, String msg) {
        Result result = new Result();
        result.setMeta(new Meta(status, msg));
        return result;
    }

    public static Result notLogin() {
        Result result = new Result();
        result.setMeta(new Meta(401, "认证失效, 请重新登录"));
        return result;
    }

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    static class Meta {
        private int status;
        private String msg;
    }

}
